﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _3._3._6_单例模式
{
    internal class Program
    {
        static void Main(string[] args)
        {
       

            // 获取Singleton类的唯一实例
            Singleton singleton =Singleton.Instance;
            
            singleton.PerformOperation();

            // 使用这个实例，例如打印它的_state字段
            var aaa = singleton.State;
            singleton.UpdateState(99);
            Console.Write("新值为：");
           
            singleton.PerformOperation();
            Console.WriteLine( "记录值，" +aaa);


            Singleton singleton2 = Singleton.Instance;
            Console.WriteLine("-------- singleton2----------");
            singleton2.PerformOperation();//新的实例值受第一个实例影响
            Console.WriteLine("------------------");
            






            Console.ReadKey();
        }
    }
}
